package org.gfix.binding;

import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Simple caching holder for the cached parsing of the Fix annotations for
 * the given class, this allows cache implementations to be cleared etc when bindings 
 * are updated.
 * 
 * @author alan
 *
 */
public class BindingCache {

	private Map<Class<?>, ClassFixBindingDescription> bindingCache = 
		new ConcurrentHashMap<Class<?>, ClassFixBindingDescription>();
	
	public void clear()
	{
		bindingCache.clear();
	}
	
	public ClassFixBindingDescription getFixBinding(Class<?> type)
	{
		return bindingCache.get(type);
	}
	
	public void addFixBinding(Class<?> type, ClassFixBindingDescription description)
	{
		bindingCache.put(type,description);
	}

	public Collection<ClassFixBindingDescription> getAllBindings() {
		return bindingCache.values();
	}
	
}
